﻿

namespace Mulala.Cavan.Presentation.Mvc.Controller
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Mulala.Cavan.Presentation.Seedwork;
    using Mulala.Cavan.Domain.MainBoundedContext.CorporationModule;
    using Mulala.Cavan.Domain.MainBoundedContext.SearchModule;
    using Mulala.Cavan.Presentation.Mvc.ViewModel;
    using Mulala.Cavan.Application.MainBoundedContext.CorporationModule;
    using System.Web.Mvc;
    using Mulala.Cavan.Domain.MainBoundedContext.Setting;

    public class CorporationNewController : EntityController<CorporationNew, CorporationNewSearch, ICorporationNewViewModel, ICorporationNewAppService>, ICorporationNewController
    {
        public override string ControllerName
        {
            get { return ControllerConst.CORPORATIONNEW; }
        }

        public override bool UseDenied
        {
            get { return false; }
        }

        [ActionName("news")]
        public ActionResult GetNews(int id, int cp)
        {
            IDictionary<string, bool> orderBy = new Dictionary<string, bool>();
            orderBy.Add("EditTime", true);

            CorporationNewSearch corporationNewSearch = CorporationNewSearchFactory.CreateCorporationNewSearch(id, orderBy, cp, Project.Settings.MaxRowsPerPage);

            long total = 0;
            IList<CorporationNew> corporationNews = this.AppService.GetBySearch(corporationNewSearch, out total).ToList();

            return View(corporationNews);
        }

        [ActionName("newdetail")]
        public ActionResult GetNew(int id)
        {
            CorporationNew corporationNew = this.AppService.GetById(id);

            return View(corporationNew);
        }
    }
}
